﻿using System.Windows;
using System.Windows.Controls;

namespace Dsl.Ped.Controls.ProjectiveControl
{
    /// <summary>
    /// This is the <see cref="Control"/> implementing a transition that can be used
    /// in a context of <see cref="ProjectionContainerControl"/>. It defines a transition
    /// among two projections together with an <see cref="Event"/> that invokes the change
    /// of <see cref="FromProjection"/> into <see cref="ToProjection"/>.
    /// </summary>
    public class TransitionControl : Control
    {
        /// <summary>
        /// Property refering to the event that must be raised to invoke 
        /// the change of a projection 
        /// </summary>
        public static DependencyProperty EventProperty;

        /// <summary>
        /// Name of the projection that must be active to invoke the change to another 
        /// projection when the event defined in <see cref="EventProperty"/> occures.
        /// </summary>
        public static DependencyProperty FromProjectionProperty;

        /// <summary>
        /// Name of the projection to which the <see cref="ProjectionContainerControl"/> should
        /// change the active projection
        /// </summary>
        public static DependencyProperty ToProjectionProperty;

        /// <summary>
        /// Static constructor. Registers all <see cref="DependencyProperty"/> properties
        /// </summary>
        static TransitionControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TransitionControl), new FrameworkPropertyMetadata(typeof(TransitionControl)));

            EventProperty = DependencyProperty.Register(
                "Event", typeof(string), typeof(TransitionControl),
                new FrameworkPropertyMetadata(string.Empty));

            FromProjectionProperty = DependencyProperty.Register(
                "FromProjection", typeof(string), typeof(TransitionControl),
                new FrameworkPropertyMetadata(string.Empty));

            ToProjectionProperty = DependencyProperty.Register(
                "ToProjection", typeof(string), typeof(TransitionControl),
                new FrameworkPropertyMetadata(string.Empty));
        }

        /// <summary>
        /// Event defined for the <see cref="TransitionControl"/>
        /// </summary>
        public string Event
        {
            get { return (string) GetValue(EventProperty); }
            set { SetValue(EventProperty, value); }
        }

        /// <summary>
        /// Source projection name defined for the <see cref="TransitionControl"/>
        /// </summary>
        public string FromProjection
        {
            get { return (string) GetValue(FromProjectionProperty); }
            set { SetValue(FromProjectionProperty, value); }
        }

        /// <summary>
        /// Target projection name defined for the <see cref="TransitionControl"/>
        /// </summary>
        public string ToProjection
        {
            get { return (string)GetValue(ToProjectionProperty); }
            set { SetValue(ToProjectionProperty, value); }
        }
    }
}
